<!DOCTYPE html>
<html>
<head>	
	<title>{:C('SERVER_HOME_NAME')}</title>

	<meta charset="utf-8">
	<meta name="viewport" content="width=device-width">
	<link rel="stylesheet" type="text/css" href="__PUBLIC__/css/style.css" />		
	<link rel="stylesheet" href="__PUBLIC__/redactor/css/redactor.css" />
</head>
<body>
	<div class="box">
		<include file="Public/top" />
		<div class="content">
			<include file="leftNav" />
			<div class="main p30">
				<h3>文案代写</h3>
                <form action="__URL__/writeServiceForm" method="post" onSubmit="return beforeSubmit(this);">
					<table>
						<tbody>
							<tr><td class="lable">分类</td></tr>
							<tr class="tbs-btn writeType">
								<td>
									<volist id="vo" name="writeType">
										<span data-val="{$vo.id}">{$vo.title|default='--'}</span>
									</volist>
	                                <input type="hidden" name="writeType">
                                </td>
							</tr>
							<tr><td class="lable">套餐</td></tr>
							<tr class="tbs-btn typePackage">
								<td>
									<volist id="vo" name="typePackage">
										<span data-val="{$vo.id}" data-money="{$vo.money}">{$vo.title|default='--'}</span>
									</volist>
	                                <input type="hidden" name="typePackage" >
                                </td>
							</tr>
							<tr><td class="lable">篇数</td></tr>
							<tr>
								<td>
									<select name="number" class="select-price">
										<option>1</option>
										<option>2</option>
										<option>3</option>
										<option>4</option>
										<option>5</option>
									</select>
									消耗<span class="text-red" id="money">300</span>元
									<input type="hidden" name="money" value="300">
								</td>
							</tr>
							<tr>
								<td class="subject"><span><input type="text" name="title" placeholder="请输入主题"></span></td>
							</tr>
							<tr>
								<td>
								<div id="page">
									<textarea id="kind" name="content" style="width:800px;height: 400px;"></textarea>
								</div>
								</td>
							</tr>
						</tbody>		
					</table>
					<div class="btn-form">						
						<input type="submit" class="btn" value="发布">
					</div>
				</form>
			</div>
			
		</div>
	</div>

	<include file="Public/ok"/>
	
	<script type="text/javascript" src="__PUBLIC__/js/jquery-1.7.min.js"></script>
	<script src="__PUBLIC__/js/page.js"></script>

	<script charset="utf-8" src="__PUBLIC__/kindeditor/kindeditor-all.js"></script>
	<script charset="utf-8" src="__PUBLIC__/kindeditor/lang/zh-CN.js"></script>
	<script charset="utf-8" src="__PUBLIC__/kindeditor/plugins/code/prettify.js"></script>

	<script type="text/javascript">
	
			$(function () {
				//编辑框
				KindEditor.ready(function(K) {
					var editor = K.create('#kind', {
						cssPath : '__PUBLIC__/kindeditor/plugins/code/prettify.css',
						uploadJson : '__PUBLIC__/kindeditor/php/upload_json.php',
						fileManagerJson : '__PUBLIC__/kindeditor/php/file_manager_json.php',
						allowFileManager : true,
			    		afterCreate : function() {
						   this.sync(); 
						}, 
						afterBlur:function(){ 
							this.sync(); 
						}            
					});
					//prettyPrint();
				});	

				//分类选择
				$(".writeType span").on("click",function () {
					$(this).addClass("cur");
					$(this).siblings().removeClass("cur");
					var val=$(this).attr("data-val");
					$("input[name=writeType]").val(val);
				});
				//套餐选择
				$(".typePackage span").on("click",function () {
					$(this).addClass("cur");
					$(this).siblings().removeClass("cur");
					var val=$(this).attr("data-val");
					$("input[name=typePackage]").val(val);
					var money=$(this).attr("data-money");
					$("input[name=money]").val(money);
					$("#money").text(money);
					$(".select-price").val(1);
				});
		
				//消耗钻石数
				$(".select-price").on("change",function () {

					var a_money=$("input[name=money]").val();
					var money=$(this).val() * a_money;
					$(this).parent().find(".text-red").text(money);
					$("input[name=money]").val(money);
				});

			});

				//提交表单
				function beforeSubmit(form){

					if(form.writeType.value==''){
						prompting('请选择分类！');
						return false;
					}
					if(form.typePackage.value==''){
						prompting('请选择套餐！');
						return false;
					}
					if(form.number.value==''){
						prompting('请选择篇数！');
						return false;
					}
					if(form.title.value==''){
						prompting('请输入主题');
						return false;
					}
					if(form.content.value==''){
						prompting('请输入内容！');
						return false;
					}

					return true;
				}
	</script>			
</body>
</html>